package xyz.xpman.prisonerfitness.activity;

import android.app.Activity;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.RequiresApi;

import xyz.xpman.prisonerfitness.R;
import xyz.xpman.prisonerfitness.kit.DonateKit;
import xyz.xpman.prisonerfitness.util.ScreenUtil;

public class DonateWindowActivity extends Activity {


    @RequiresApi(api = Build.VERSION_CODES.P)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_donate_window);

        initPopWindow();
        initView();
    }


    private void initPopWindow() {
        // 设置窗口宽度，高度则自适应
        Point windowsSize = ScreenUtil.getWindowsSize(this);
        int width = (int)((float) windowsSize.x * 0.85);
        getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);
    }

    private void initView() {
        // 段首缩进
        String about = "\t\t\t\t" + getString(R.string.about_content);
        ((TextView) findViewById(R.id.about)).setText(about);

        // 支付宝打赏功能 https://qr.alipay.com/xxxxxx?t=yyyyyy ?t=1621987150720
        findViewById(R.id.donate).setOnClickListener(view
                -> DonateKit.run(this));
    }
}